﻿package mortal.game.view.mainUI.smallMap.view
{
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import mortal.common.*;
    import mortal.game.view.common.*;
    import mortal.game.view.mainUI.smallMap.view.data.*;
    import mortal.game.view.mainUI.smallMap.view.render.*;

    public class SmallMapWorldRegion extends GSprite
    {
        private var _items:Array;
        private var _datas:Array;
        private var _bg:GImageBitmap;

        public function SmallMapWorldRegion()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._items = [];
            this._bg = UIFactory.gImageBitmap(null, 0, -45, this);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            DisplayUtil.delNotUse(this._items, 0);
            this._items = [];
            this._bg.dispose(param1);
            this._bg = null;
            this._datas = null;
            return;
        }// end function

        public function updateAll(param1:Array) : void
        {
            var _loc_3:SmallMapWorldRegionData = null;
            var _loc_4:SmallMapWorldRegionItem = null;
            if (this._datas == param1)
            {
                return;
            }
            this._datas = param1;
            var _loc_2:int = 0;
            while (_loc_2 < this._datas.length)
            {
                
                _loc_3 = this._datas[_loc_2];
                _loc_4 = this.getItem(_loc_2);
                _loc_4.update(_loc_3);
                if (_loc_2 == 0)
                {
                    LoaderHelp.setBitmapdata(_loc_3.bgUrl + ".jpg", this._bg);
                }
                if (_loc_4.parent == null)
                {
                    this.addChild(_loc_4);
                }
                _loc_2++;
            }
            DisplayUtil.delNotUse(this._items, _loc_2);
            return;
        }// end function

        private function getItem(param1:int) : SmallMapWorldRegionItem
        {
            var _loc_2:* = this._items[param1];
            if (_loc_2 == null)
            {
                _loc_2 = UICompomentPool.getUICompoment(SmallMapWorldRegionItem) as SmallMapWorldRegionItem;
                _loc_2._selectedCallback = this.clearAllSelected;
                this._items[param1] = _loc_2;
                this.addChild(_loc_2);
            }
            return _loc_2;
        }// end function

        private function clearAllSelected() : void
        {
            var _loc_1:SmallMapWorldRegionItem = null;
            if (this._items == null)
            {
                return;
            }
            for each (_loc_1 in this._items)
            {
                
                _loc_1.clearSelected();
            }
            return;
        }// end function

    }
}
